package com.whmnx.main.ui.model;

import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.whmnx.base.bean.ProductBean;
import com.whmnx.main.ui.fragment.CanTeamDetailsFragment;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.base.ItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

/**
 * author : huang
 * date   : 2020/10/14 0014 11:59
 * version: 1.0
 * @author Administrator
 */
public class AddComItemViewModel extends ItemViewModel {
    public ObservableField<String> Product_sec  = new ObservableField<>("");

    public ObservableField<String> Product_price  = new ObservableField<>("");

    public ObservableField<String> Product_price_pin  = new ObservableField<>("");

    private CommodityModel viewModel;
    private ProductBean.SpecModelBean specModelBean;

    public AddComItemViewModel(@NonNull CommodityModel viewModel, ProductBean.SpecModelBean specModelBean) {
        super(viewModel);
        this.specModelBean = specModelBean;
        this.viewModel = viewModel;
        if (TextUtils.isEmpty(specModelBean.getProductSPEC_Name())){
            Product_sec.set(specModelBean.ProductSPEC_Name);
        }else {
            Product_sec.set(specModelBean.getProductSPEC_Name());
        }
        if (TextUtils.isEmpty(specModelBean.getProductSPEC_Price())){
            Product_price.set(specModelBean.ProductSPEC_Price);
        }else {
            Product_price.set(specModelBean.getProductSPEC_Price());
        }
    }


    public BindingCommand delOnClickCommand = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            viewModel.deleteItem(AddComItemViewModel.this,specModelBean);
        }
    });
}
